package com.jt.common.utils;
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
/*LTAI4GCDWPRsdG6a7qRrqUCY

IXdxB04HKjrxiJf1xlZcRqQMzZgdUI*/


/*<dependencies>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.4.6</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-ecs</artifactId>
<version>4.17.6</version>
</dependency>
</dependencies>*/

public class MSUtil {

    public static void sendMs(String phoneNum,String verify) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAI4GCDWPRsdG6a7qRrqUCY", "IXdxB04HKjrxiJf1xlZcRqQMzZgdUI");
        IAcsClient client = new DefaultAcsClient(profile);
        CommonRequest request = new CommonRequest();
        request.setMethod(MethodType.POST);
        request.setDomain("dysmsapi.aliyuncs.com");
        request.setVersion("2017-05-25");
        request.setAction("SendSms");
        request.putQueryParameter("RegionId", "cn-hangzhou");
        request.putQueryParameter("PhoneNumbers", phoneNum);
        request.putQueryParameter("SignName", "小仙女商城");
        request.putQueryParameter("TemplateCode", "SMS_204460270");
        request.putQueryParameter("TemplateParam", "");
        request.putQueryParameter("TemplateParam", "{\"code\":\""+verify+"\"}");

        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }
}
